<template>
    <div class="leave-myleave">
        <Row class="leave-myleave-rows">
            <Col span="5">{{"教师姓名："}}</Col>
            <Col span="19">{{data.teacher.teacher_name.zh}}</Col>
        </Row>
        <Row class="leave-myleave-rows">
            <Col span="5">{{"请假种类："}}</Col>
            <Col span="19">{{data.teacher_leave_kinds[0].dictionary_name.zh}}</Col>
        </Row>
        <Row class="leave-myleave-rows">
            <Col span="5">{{"请假开始时间："}}</Col>
            <Col span="19">{{data.start_time}}</Col>
        </Row>
        <Row class="leave-myleave-rows">
            <Col span="5">{{"请假结束时间："}}</Col>
            <Col span="19">{{data.end_time}}</Col>
        </Row>
        <Row class="leave-myleave-rows">
            <Col span="5">{{"请假天数："}}</Col>
            <Col span="19">{{data.leave_days==null ? '' : `${data.leave_days}天`}}</Col>
        </Row>
        <Row class="leave-myleave-rows">
            <Col span="5">{{"是否调课："}}</Col>
            <Col span="19">{{data.whether_class== 1 ? "是" : "否"}}</Col>
        </Row>
        <Row class="leave-myleave-rows">
            <Col span="5">{{"教师请假原因："}}</Col>
            <Col span="19">{{data.teacher_leave_reason.zh!=null ? data.teacher_leave_reason.zh : ''}}</Col>
        </Row>

        <div class="sub-cont">
            <p class="sub-tr">请假审核记录</p>
            <Table :columns="columns1" :data="datalist" height="300" v-if="this.datalist.length!=0"></Table>
        </div>

        <div class="sub-cont" v-if="data.whether_class==1">
            <Spin size="large" fix v-if="spinShow"></Spin>
            <p class="sub-tr">调课记录</p>
            <Table :columns="columns2" :data="whetherlist" height="300"></Table>
        </div>
    </div>
</template>

<script> 
    export default {
    props:['data'],
    data() {
        return {
            spinShow:false,
            whetherlist:[],            
            datalist:[],
            columns1: [
                {
                    title: '审核人姓名',
                    render: (h, params) => {                         
                        return h('div', params.row.teacher!=null?params.row.teacher.teacher_name.zh:'');
                    }
                },
                {
                    title: '审核状态',
                    render: (h, params) => {
                        let col='';
                        let name='';
                        if(params.row.status=='0'){
                            col='#007d7f';
                            name='未审核';
                        }else if(params.row.status=='1'){
                            col='#1aad33';
                            name='通过';
                        }else if(params.row.status=='2'){
                            col='#f00';
                            name='未通过';
                        }else{
                            col='#FFC107';
                            name='同意并向上级审批';
                        }
                        return h('div',{
                            style: {
                                color: col,
                            },
                        }, name);
                    }
                },
                {
                    title: '时间',
                    render: (h, params) => {
                        return h('div', params.row.created_at);
                    }
                },
            ],
            columns2: [
                {
                    title: '请假开始时间',
                    render: (h, params) => {                      
                        return h('div', params.row.start_time);
                    }
                },
                {
                    title: '请假结束时间',
                    render: (h, params) => {                      
                        return h('div', params.row.end_time);
                    }
                },
                {
                    title: '调课安排',
                    render: (h, params) => {
                        let ss = `${params.row.date + params.row.week_id.dictionary_name.zh + params.row.class_type.name.zh + params.row.course_id.course_name.zh}`;                         
                        return h('div', ss);
                    }
                },
                {
                    title: '调课教师',
                    render: (h, params) => {
                        return h('div', params.row.to_teacher!=null?params.row.to_teacher.teacher_name.zh:'');
                    }
                },
            ],
        }
    },
    methods: {
        Information(){  
            this.spinShow = true           
            this.datalist = this.data.examine 
            if(this.data.whether_class==1){             
                this.$http.get(`api/leave/v1/teacher_leave/my_course/${this.data.teacher_leave_id}`).then((response) => {
                    this.whetherlist = response.data
                    this.spinShow = false 
                }).catch(err => {
                    if (err.code && err.code == 422) {
                        this.$Message.error(err.message);
                    }
                })
            }else{
                this.spinShow = false               
            }
        },

    },
    created() {
        this.Information()
    }

  }
</script>

<style lang="less">
.leave-myleave{
    &-rows{
        padding: 8px 0 2px 0;
        font-size: 14px;
    }
    .sub-cont{
        width: 100%; 
        padding: 10px 0px;
        position: relative;
    }
    .sub-tr{
        padding: 5px 0px;
        font-size: 13px;
        color: #495060;
    }
    .cont-bor{
        border-top:1px solid #d9d9dd;    
    }
}
</style>
